package testdemo;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 黎鹤舞
 * Date: 2023-12-02
 * Time: 12:12
 */
class Solution {

    //逆序函数
    public void inverse(int[] nums,int left,int right) {
        while(left < right) {
            int temp = nums[left];
            nums[left] = nums[right];
            nums[right] = temp;
            left++;
            right--;
        }
    }
    public void rotate(int[] nums, int k) {
        inverse(nums,0,nums.length);
        inverse(nums,0,k);
        inverse(nums,k,nums.length);
    }
    public static void main(String[] args) {
        int[] arrays = new int[]{1,2,3,4,5,6,7};
        Solution solution = new Solution();
        solution.rotate(arrays,3);
    }
}